package com.ict.web.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.ict.common.annotation.Excel;
import com.ict.common.utils.bean.BeanUtils;
import com.ict.common.utils.uuid.IdUtils;
import com.ict.web.constant.Constants;
import com.ict.web.domain.AnnualProjectPlan;
import com.ict.web.domain.ProjectManagement;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;
import java.util.Date;

@Data
public class AnnualProjectPlanAddDto {
    /** 计划名称 */
    @ApiModelProperty(value = "计划名称")
    @NotBlank(message = "计划名称不能为空")
    private String name;

    /** 年份 */
    @ApiModelProperty(value = "年份")
    @NotBlank(message = "年份不能为空")
    private String year;

    /** 起始时间 */
    @ApiModelProperty(value = "起始时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8",shape = JsonFormat.Shape.STRING)
    @NotNull(message = "起始时间不能为空")
    private LocalDateTime startTime;

    /** 截至时间 */
    @ApiModelProperty(value = "截至时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8",shape = JsonFormat.Shape.STRING)
    @NotNull(message = "截至时间不能为空")
    private LocalDateTime endTime;

    /**
     * 将 AnnualProjectPlanAddDto 转化为 AnnualProjectPlan
     *
     * @param dto 接收dto
     * @return HotelInfo
     */
    public static AnnualProjectPlan of(AnnualProjectPlanAddDto dto){
        AnnualProjectPlan bean = new AnnualProjectPlan();
        BeanUtils.copyProperties(dto,bean);

        //设置ID
        bean.setPlanId(IdUtils.snowId());
        //设置创建时间
        bean.setCreateTime(LocalDateTime.now());
        //设置创建时间
        bean.setUpdateTime(LocalDateTime.now());
        //设置物理删除标记
        bean.setIsDelete("0");
        //设置默认 状态 (未启动)
        bean.setIsState(Constants.ANNUAL_PROJECT_PLAN_NOT_STARTED);

        return bean;
    }

}
